package com.mayikt.service;


import java.util.ServiceLoader;

/**
 * @ClassName Test002
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test002 {
    public static void main(String[] args) {
//        System.out.println(Test002.class.getClassLoader().getParent().getParent());
        //设置为启动类加载器
//        Thread.currentThread().setContextClassLoader(Test002.class.getClassLoader().getParent().getParent());
        // 扩展类加载器
        Thread.currentThread().setContextClassLoader(Test002.class.getClassLoader().getParent());
        ServiceLoader<MayiktService> load = ServiceLoader.load(MayiktService.class);
        load.forEach((t) -> {
            System.out.println(t);
        });


    }
}
